# Contributor: Brandon Boese <brandonboese@protonmail.com>
# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=qtmir
pkgver=0.7.2
pkgrel=0
pkgdesc="QPA plugin to make Qt a Mir server"
# armhf: blocked by lots of dependencies
# riscv64: blocked by valgrind
arch="all !armhf !riscv64"
url="https://gitlab.com/ubports/development/core/qtmir"
license="LGPL-3.0-only"
makedepends="
	cgmanager-dev
	cmake
	cmake-extras
	gsettings-qt-dev
	gtest-dev
	libqtdbusmock
	libqtdbustest
	lomiri-app-launch-dev
	lomiri-content-hub-dev
	lomiri-url-dispatcher-dev
	lttng-ust-tools
	mir-dev
	process-cpp-dev
	qt5-qtdeclarative-dev
	qt5-qtsensors-dev
	samurai
	valgrind-dev
	"
checkdepends="
	dbus
	py3-dbusmock
	"
source="https://gitlab.com/ubports/development/core/qtmir/-/archive/$pkgver/qtmir-$pkgver.tar.gz
	0001-Wayland-hack-set-maliit-server-to-inputmethod-type-W.patch
	0002-Squash-of-miroil-patches.patch
	0003-Require-miroil-in-out-.pc-file.patch
	0004-Update-for-Mir-2.15-removals.patch
	"
subpackages="$pkgname-dev"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DWITH_MIR2=ON
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove files for testing only
	# https://gitlab.com/ubports/development/core/qtmir/-/blob/main/debian/qtmir-tests.install
	rm "$pkgdir"/usr/bin/qtmir-demo-client
	rm "$pkgdir"/usr/bin/qtmir-demo-shell
	rm "$pkgdir"/usr/share/applications/qtmir-demo-client.desktop
	rm "$pkgdir"/usr/share/applications/xwayland.qtmir.desktop
	rm "$pkgdir"/usr/share/qtmir/benchmarks/common.py
	rm "$pkgdir"/usr/share/qtmir/benchmarks/report_types.py
	rm "$pkgdir"/usr/share/qtmir/benchmarks/touch_event_latency.py
	rm "$pkgdir"/usr/share/qtmir/benchmarks/touch_event_latency.R
	rmdir "$pkgdir"/usr/share/applications/
	rm -r "$pkgdir"/usr/share/qtmir/qtmir-demo-client/
	rm -r "$pkgdir"/usr/share/qtmir/qtmir-demo-shell/
	rm -r "$pkgdir"/usr/share/qtmir/benchmarks/
	rmdir "$pkgdir"/usr/share/qtmir/
}

sha512sums="
17b59f4056b3dd7509201a3d575c3c018f278e9e08fdef3d38049f95b48389f87a6154d569db242e705f68d6b09916319f4d9d6ee3b3e5faea0299a9d9770d83  qtmir-0.7.2.tar.gz
f6481e3fff1b00066d2292e8273bd1dc5759d65e8eb5dba5e1400ba4570663933a8ed5e42bbf0207a96a9733b30256c1ee70055f25d93fcb862dff72e9bc0d1d  0001-Wayland-hack-set-maliit-server-to-inputmethod-type-W.patch
bd783233deb19bb1feda66b30c57fa565482c809f161d2065da882fd497d3f8f8678e0414a181e2386c2b633a0099e0e80d4f1057623abfff817b6619100b724  0002-Squash-of-miroil-patches.patch
b99d9c84921e8374e6596825de9b3ed120d461b2a2627cf98bb31b306db6f49a919e5a1f40eb0ffdb4986ea463d6e90a6bd3c29c5ed4147c6c6b1bd85628501d  0003-Require-miroil-in-out-.pc-file.patch
d828204c95458d33ffd6364c3a25a8151fc1503ed81415655a86dbc1cd4d47a2ba5b0d6d30d9f17416a82901ec250b22e09fbbd367f3c63094b2d8a83cb3518a  0004-Update-for-Mir-2.15-removals.patch
"
